module.exports = class extends think.Model {
  async getSystem_info() {
    const system_info = await this.field('name,value').select();
    let info = {};
    for (let itemInfo of system_info) {
      info[itemInfo.name] = itemInfo.value;
    }
    return info;
  }

  async update_system_info(info) {
    let affectedRows = true;
    for (let item_name of Object.keys(info)) {
      think.logger.debug(item_name, info[item_name] + '')
      let where = {};
      where.name = item_name;
      affectedRows = await this.where(where).update({value: info[item_name]});
      if (!affectedRows) {
        break;
      }
    }
    return affectedRows;
  } 
}